﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html; charset=UTF-8" language="java" pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>
<%@include file="/common/javascript.jsp" %>
<html xmlns="http://www.w3.org/1999/xhtml" id="teacherForm">
<head>
    <title>通告发布</title>
   
    <script type="text/javascript">
    var mainform;
    var viewType = "${viewType}";
    var flag=false; 
    
    $(function (){
    	
    	$("#date").ligerDateEditor();
    
        mainform=$("#mainform");
        
        mainform.ligerForm();
        
        //如果是修改视图,主键不可编辑
        if(viewType=="modify"){
        	 $("#id").attr("readonly", "readonly").removeAttr("validate");
        	 $("#date").ligerDateEditor({initValue:'${command.date}'});
        }
        
        //如果是详细试图,所有字段不可编辑
        if(viewType=="detail"){
        	$("input,select,textarea",mainform).attr("readonly", "readonly");
        }else{
            $.metadata.setType("attr", "validate");
            LG.validate(mainform);
        }
        
        //渲染按钮
        LG.setFormDefaultBtn(cancel,viewType=="detail" ? null : save);  
    });
    
    function save(){
    	LG.submitForm(mainform, function (result) {
        	if(typeof(result)=="string"){
        		result=eval("("+result+")");
        	}
            if (!result.success) {
                LG.showError('错误:' + result.message);
            }
            else { 
                LG.showSuccess('保存成功', function () { 
                   LG.callParent("clsList");
                });
            }
        });
     /*     */
    }
    function cancel(){
        var win = window.parent || window;
        if(win.dialog){
        	win.dialog.close();
        }
    }
   
 </script>
</head>

<body>
    <form name="mainform" method="post"  id="mainform" action="${ctx }/qso/announceh/save">
        <input type="hidden" name="viewType" value="${viewType}"/>
        <table cellpadding="0" cellspacing="0" class="l-table-edit" style="width: 95%; margin-top:10px; margin-left:15px;">
            <tr>
                <td align="right" class="l-table-edit-td">公告人:</td>
                <td align="left" class="l-table-edit-td">
                	${command.user.userNameC}
                </td>
                <td align="right" class="l-table-edit-td">公告日期:</td>
                <td align="left" class="l-table-edit-td">
                <c:if test="${viewType!='detail'}">
					 <input name="date" type="text" id="date"
							value="${command.date}" ltype="date" format="yyyy-MM-dd"
							validate="{required:true, notnull:true}" nullText="不能为空" />
				 </c:if> 
				 <c:if test="${viewType=='detail'}">
						<input type="text" value="${command.date}" disabled="disabled" />
				 </c:if> 
                </td>
            </tr>
            <tr>
                <td align="right" class="l-table-edit-td">公告对象:</td>
                <td align="left" class="l-table-edit-td"><select
					name="classId" id="classId" ltype="select" validate="{required:true, notnull:true}" nullText="不能为空" 
					style="width: 100%" onchange="onChangeSelected()">
						<option value="all">所有班级</option>
						<c:forEach items="${clses}" var="cls">
							<c:choose>
								<c:when test="${command.clsId.clsId eq cls.clsId}">
									<option value="${cls.clsId}" selected="selected">${cls.clsTitle}</option>
								</c:when>
								<c:otherwise>
									<option value="${cls.clsId}">${cls.clsTitle}</option>
								</c:otherwise>
							</c:choose>
						</c:forEach>
				</select></td>
            </tr>
            <tr>
                <td align="right" class="l-table-edit-td" valign="top">公告标题:</td>
                <td align="left" class="l-table-edit-td" colspan="3"> 
                <textarea cols="100" rows="1" class="l-textarea" id="title" name="title" style="width:500px" validate="{required:true, notnull:true}" nullText="不能为空" 
                <c:if test="${viewType=='detail'}">disabled="disabled"</c:if> >${command.title}</textarea>
                </td> <td align="left"></td>
           </tr>
            <tr style="margin-bottom:100px;">
                <td align="right" class="l-table-edit-td" valign="top">公告内容:</td>
                <td align="left" class="l-table-edit-td" colspan="3"> 
                <textarea cols="100" rows="3" class="l-textarea" id="content" name="content" style="width:500px" validate="{required:true, notnull:true}" nullText="不能为空"
                <c:if test="${viewType=='detail'}">disabled="disabled"</c:if> >${command.content}</textarea>
                </td> <td align="left"></td>
           </tr>
        </table>
    </form>
    <div style="height:80px"></div>
</body>

</html>
